<?php

namespace app\admin\model;

use app\admin\model\BaseModel;


class ProductInfo extends BaseModel
{

    protected $name = "product_info";
    protected $pk = "id";
    // 追加属性
    protected $append = [
        'flag_text',

    ];
    protected $deleteTime = false;

    public function getFlagTextAttr($value, $data)
    {

        $value = $value ? $value : (isset($data['flag']) ? $data['flag'] : '');
        $valueArr = is_array($value) ? $value : explode(',', $value);
        $list = $this->getFlagList();
        return implode(',', array_intersect_key($list, array_flip($valueArr)));
    }

    public function getFlagList()
    {
        return ['1' => '独立站', '2' => 'tiktok'];
    }
}
